﻿using System.Data.Entity.Design.PluralizationServices;
using System.Globalization;
using System.Threading;

namespace StudyTracker.Util
{
	public static class StringExtensions
	{
		public static string ToTitleCaseAndPlural(this string value)
		{
			return value.ToTitleCase().ToPlural();
		}

		public static string ToTitleCaseAndSingular(this string value)
		{
			return value.ToTitleCase().ToSingular();
		}

		public static string ToTitleCase(this string value)
		{
			CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
			TextInfo textInfo = cultureInfo.TextInfo;

			return textInfo.ToTitleCase(value);
		}

		public static string ToPlural(this string value)
		{
			return PluralizationService.CreateService(new CultureInfo("en-US")).Pluralize(value);
		}

		public static string ToSingular(this string value)
		{
			return PluralizationService.CreateService(new CultureInfo("en-US")).Singularize(value);
		}
	}
}
